package com.hjm.project.baseinfoClass.baseinfoClass.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.baseinfoClass.baseinfoClass.domain.BaseinfoClass;
import com.hjm.project.baseinfoClass.baseinfoClass.service.IBaseinfoClassService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 基本信息控件Controller
 * 
 * @author LOVE
 * @date 2020-11-28
 */
@Controller
@RequestMapping("/baseinfoClass/baseinfoClass")
public class BaseinfoClassController extends BaseController
{
    private String prefix = "baseinfoClass/baseinfoClass";

    @Autowired
    private IBaseinfoClassService baseinfoClassService;

    @RequiresPermissions("baseinfoClass:baseinfoClass:view")
    @GetMapping()
    public String baseinfoClass()
    {
        return prefix + "/baseinfoClass";
    }

    /**
     * 查询基本信息控件列表
     */
    @RequiresPermissions("baseinfoClass:baseinfoClass:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseinfoClass baseinfoClass)
    {
        startPage();
        List<BaseinfoClass> list = baseinfoClassService.selectBaseinfoClassList(baseinfoClass);
        return getDataTable(list);
    }

    /**
     * 导出基本信息控件列表
     */
    @RequiresPermissions("baseinfoClass:baseinfoClass:export")
    @Log(title = "基本信息控件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseinfoClass baseinfoClass)
    {
        List<BaseinfoClass> list = baseinfoClassService.selectBaseinfoClassList(baseinfoClass);
        ExcelUtil<BaseinfoClass> util = new ExcelUtil<BaseinfoClass>(BaseinfoClass.class);
        return util.exportExcel(list, "baseinfoClass");
    }

    /**
     * 新增基本信息控件
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存基本信息控件
     */
    @RequiresPermissions("baseinfoClass:baseinfoClass:add")
    @Log(title = "基本信息控件", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseinfoClass baseinfoClass)
    {
        return toAjax(baseinfoClassService.insertBaseinfoClass(baseinfoClass));
    }

    /**
     * 修改基本信息控件
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BaseinfoClass baseinfoClass = baseinfoClassService.selectBaseinfoClassById(id);
        mmap.put("baseinfoClass", baseinfoClass);
        return prefix + "/edit";
    }

    /**
     * 修改保存基本信息控件
     */
    @RequiresPermissions("baseinfoClass:baseinfoClass:edit")
    @Log(title = "基本信息控件", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseinfoClass baseinfoClass)
    {
        return toAjax(baseinfoClassService.updateBaseinfoClass(baseinfoClass));
    }

    /**
     * 删除基本信息控件
     */
    @RequiresPermissions("baseinfoClass:baseinfoClass:remove")
    @Log(title = "基本信息控件", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(baseinfoClassService.deleteBaseinfoClassByIds(ids));
    }
}
